#define _CRT_SECURE_NO_WARNINGS 1
#include"BinaryTree.h"
typedef struct TreeNode {
    int val;
    struct TreeNode* left;
    struct TreeNode* right;
    
}TreeNode;

bool isSameTree(struct TreeNode* p, struct TreeNode* q)
{
    if (p == NULL && q == NULL)
    {
        return true;
    }
    if(p == NULL || q == NULL)
    {
        return false;
    }

    if (p->val != q->val)
    {
        return false;
    }
    bool temp1 = isSameTree(p->left, q->left);
    bool temp2 = isSameTree(p->right, q->right);
    return temp1 && temp2;
}


TreeNode* Buynode(int x)
{
   
    TreeNode* newNode = (TreeNode*)malloc(sizeof(TreeNode));
    if (newNode == NULL)
    {
        perror("malloc fail!!");
    }
    newNode->left = NULL;
    newNode->right = NULL;
    newNode->val = x;
    return newNode;
}


int main()
{
    TreeNode* p1 =  Buynode(10);
    TreeNode* p2 = Buynode(5);
    TreeNode* p3 = Buynode(15);
    TreeNode* q1 = Buynode(10);
    TreeNode* q2 = Buynode(5);
    TreeNode* q3 = Buynode(15);
    p1->left = p2;
    p1->right = p3;
    q1->left = q2;
    q2->right = q3;
  bool ret= isSameTree(p1,q1);
  printf("%d ",ret);
	return 0;
}